using System.IO;
using NUnit.Framework;
using TDUnit.Common.Logging;
using TDUnit.Loggers;

namespace TDUnit.Tests
{
    [TestFixture]
    public class FileLoggerTests
    {
        [Test]
        public void CreatingLoggerWithNoPathUsesDefaultLogFileName()
        {
            var logger = new FileLogger();
            Assert.Greater(logger.LogFile.Length, 0);
        }

        [Test]
        public void WriteLogEntryWritesEntryToLogFile()
        {
            const string filePath = "log.txt";

            try
            {
                Assert.IsFalse(File.Exists(filePath), "Log file already exists.");
                using (var logger = new FileLogger(filePath))
                {
                    logger.LogMessage("Some test log message.", MessageType.Information);
                }
                Assert.IsTrue(File.Exists(filePath));
            }
            finally
            {
                File.Delete(filePath);
            }
        }
    }
}